#ifndef _DBI_${_macro(fullname)}_H_
#define _DBI_${_macro(fullname)}_H_
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include "ayoo.h"

/**
 * @brief data-storage for ${tablename} 
 * @remarks generated-code.
 */
class ${_class(tablename)}:public AYOO::BaseRow
{
public:
% for col_name, col in columns.items():
	${_struct_field(col)};
% endfor
};

/**
 * @brief data-DBI for ${tablename} 
 * @remarks generated-code.
 */
class DBI${_class(tablename)}:public AYOO::BaseDBI
{
public:
	DBI${_class(tablename)}(const std::string &sHost, uint32_t iPort, const std::string &sUser, const std::string &sPswd)
	: AYOO::BaseDBI( sHost, iPort, sUser, sPswd)
	{
	//	LOG_DEB("concrete-init.");
	}

	DBI${_class(tablename)}(const AYOO::Config& conf)
	: AYOO::BaseDBI(conf, "DB_HOST", "DB_PORT", "DB_USER", "DB_PSWD" )
	{
	}

	int32_t Insert(${_class(tablename)} &in_${_class(tablename)});
	int32_t SelectOne(uint32_t id, ${_class(tablename)} &out_${_class(tablename)});
	int32_t Select(const std::string &sCondition, uint32_t iStart, uint32_t iLimit, std::vector<${_class(tablename)}> &outlist_${_class(tablename)});
	int32_t Count(const std::string &sCondition);
	int32_t UpdateOne(${_class(tablename)} &in_${_class(tablename)});
	int32_t Update(const std::string &sCondition, ${_class(tablename)} &in_${_class(tablename)});
	int32_t DeleteOne(uint32_t id);
	int32_t Delete(const std::string &sCondition);

};

#endif /*_DBI_${_macro(fullname)}_H_*/

<%!
_type_def={
'i32':'int32_t',
'ui32':'uint32_t',
'i64':'int64_t',
'ui64':'uint64_t',
'string':'std::string',
'float':'float',
'double':'double',
'char':'int8_t',
}
def _type(t):
	if _type_def.has_key(t) :
		return _type_def[t]
	else:
		return "UNKNOWN"
%>
<%def name="_class(name)" >${name.replace('.','_').capitalize()}</%def>
<%def name="_macro(name)" >${name.replace('.','_').upper()}</%def>
<%def name="_struct_field(col)" >${_type(col.Type)} ${col.Name}</%def>
